Skip to content

Conversation

@shatfield4
Copy link
Collaborator

Pull Request Type

  • ✨ feat
  • πŸ› fix
  • ♻️ refactor
  • πŸ’„ style
  • πŸ”¨ chore
  • πŸ“ docs

Relevant Issues

resolves #4572

What is in this change?

  • Patches LM Studio race condition bug
  • Bug occurs in the constructor when we begin fetching the context windows in the background (using .then in constructor does not wait for completion before instantiating the class) and there is no check to ensure this.limits was initialized before a chat can be sent
  • This race condition bug happens when a user has lots of models in LM Studio and the API has a delay in returning the context windows causing the chat to be sent before we can get a response back from the context window LM Studio API endpoint (this.limits is not initialized)
  • Adds awaited ensureModelCached guard function to all chat methods and agent provider chat methods to block a chat from happening until we either get a response back from the LM Studio API with correct context window OR fallback to 4096 as default context window size (ensures this.limits is initialized properly)
  • Adds checks for models that may have been downloaded from LM Studio AFTER the backend server was started and fetches context windows again from the LM Studio API if the model is not already cached instead of just defaulting back to 4096 immediately when the selected model doesn't exist in cache
  • Adds test cases for both LM Studio LLM and agent providers

Additional Information

Developer Validations

  • I ran yarn lint from the root of the repo & committed changes
  • Relevant documentation has been updated
  • I have tested my code functionality
  • Docker build succeeds locally

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG]: LMStudio provided LLM stopped working with Anything LLM after upgrading to 1.9.0

3 participants